Skip to content

NXP backend: Enable constant_pad_nd with new Neutron flow.#19543

Open
MartinPavella wants to merge 1 commit into
pytorch:mainfrom
nxp-upstream:nxg01483/EIEX-865-add-constant_pad_nd-support-using-new-neutron-flow
Open

NXP backend: Enable constant_pad_nd with new Neutron flow.#19543
MartinPavella wants to merge 1 commit into
pytorch:mainfrom
nxp-upstream:nxg01483/EIEX-865-add-constant_pad_nd-support-using-new-neutron-flow

Conversation

@MartinPavella
Copy link
Copy Markdown
Collaborator

@MartinPavella MartinPavella commented May 13, 2026

Summary

Enable constant_pad_nd with new Neutron flow in NXP backend. Reflect the new Neutron requirements and verify correct function.

Test plan

Unit tests provided.

cc @robert-kalmar @JakeStevens @digantdesai @rascani

@MartinPavella MartinPavella self-assigned this May 13, 2026
@MartinPavella MartinPavella added the module: nxp Issues related to NXP Neutron NPU delegation and code under backends/nxp/ label May 13, 2026
@MartinPavella MartinPavella added the release notes: nxp Changes to the NXP Neutron backend delegate label May 13, 2026
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 13, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19543

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ You can merge normally! (2 Unrelated Failures)

As of commit 28bb54c with merge base 5971a4b (image):

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 13, 2026
@MartinPavella
Copy link
Copy Markdown
Collaborator Author

@novak-vaclav as per usual.

@MartinPavella MartinPavella force-pushed the nxg01483/EIEX-865-add-constant_pad_nd-support-using-new-neutron-flow branch from aa0cd08 to 28bb54c Compare May 13, 2026 13:05
Copy link
Copy Markdown
Contributor

@novak-vaclav novak-vaclav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! 👍 only a few pointers

# Requirements specified by the new Neutron flow documentation.

return True
return True # There are no requirements.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check for io quantization is missing


import numpy as np

# noinspection PyUnusedImports
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why is this necessary? pytest module is used and linter should not complain

assert graph_contains_any_of_ops(exec_program.graph, [ConstantPadND])


class TestConstantPadNDNewNeutronFlow:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would add comment somewhere that the padding tuples go from the last dimension to the first. It took me a while to understand it and a simple comment or hands-on example would be nice.
Something like

Order of inserted padding is backwards, ie:
p2d = (1, 1, 2, 2) # pad the last dim on both sides and second to last dim on both sides

pytest.param((1, 2, 3, 4, 5), tuple(range(4)), id="5D, padding W, D"),
],
)
def test__basic_nsys_inference(self, mocker, input_shape, paddings, use_qat):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget QAT variant.

print(
f"NPU output doesn't match reference. Maximum absolute difference: {max_diff}"
)
assert all_close
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: nxp Issues related to NXP Neutron NPU delegation and code under backends/nxp/ release notes: nxp Changes to the NXP Neutron backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants